<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - timing functions in keyframes</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#timing-functions-for-keyframes-">
   <meta name="flags" content="dom">
   <meta name="assert" content="A keyframe style rule may declare the timing
   function that is to be used as the animation moves to the next keyframe">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes step-right {
         from {
            left: 0px;
            animation-timing-function: steps(2, end);
         }
         50% {
            left: 50px;
            animation-timing-function: steps(1);
         }
         to {
            left: 100px;
            animation-timing-function: ease-in;
         }
      }
      div {
         width: 100px;
         height: 100px;
         background: blue;
         position: relative;
      }
      .test {
         animation: step-right 1.6s forwards;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var div = document.querySelector('div');
         var log = document.querySelectorAll('p')[1].firstChild;
         var passed = false;
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 2000);
         div.addEventListener('animationstart', function() {
            passed = (getComputedStyle(div, null).left == '0px');
         });
         div.addEventListener('animationend', function() {
            clearTimeout(timeout);
            passed = (passed && getComputedStyle(div, null).left == '100px');
            test(function(){assert_true(passed);}, testName); done();
            log.data = passed ? 'PASS if the animation occurred.' : 'FAIL';
         });
         setTimeout(function() {
            passed = (passed && getComputedStyle(div, null).left == '25px');
         }, 600);
         setTimeout(function() {
            passed = (passed && getComputedStyle(div, null).left == '50px');
         }, 1400);
         div.className = 'test';
      }
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>The square below should move rightwards in two small steps, then pause,
   and finally move one bigger step.</p>
   <p>Testing...</p>
   <div></div>
</body>
</html>
